
local locplayer = ac.player.self
local w,h = 420,85
local ui = class.panel:builder 
{
    x = (1920 - w) / 2,
    y = 780,
    w = w,
    h = h,
    alpha = 0.99,
    level = 99,
    show_flag = false,
    fdf = 'tooltip_backdrop0',
}

local w1,h1 = 64,64
local x1 = 15
local y1 = 10
ui.buttons = {}
for a=1,6 do
    local x = (a-1) * (w1 + 1) + x1
    local panel = ui:add_card_button(x,y1,w1,h1)
    table.insert(ui.buttons,panel)
end

--离开
ui.show_time = 0

function ui:update(frame)
    local data = locplayer:get_data('拥有符文列表')
    for i,button in ipairs(self.buttons) do
        local skill = data and data[i]
        button:set_data(skill)
    end
    
end

function ui:on_button_mouse_enter(button)
    local skill = button.skill
    if skill then
        local title = format_obj(skill,skill.title or skill.name)
        local tip = format_obj(skill,skill.tip)
        local ui = button:tooltip(title,tip,'top')
        --self:set_tooltip_follow(ui, 'right',0,-(self.h-ui.h)/2)
    end
end


local button = ui:add_button('',0,0,nil,35)
button.drag_flag = true

function button:on_button_mouse_down()
    local x,y = ac.hardware:get_mouse_pos()
    self.start_x = x
    self.start_y = y
end

function button:on_button_drag(x,y)
    ui:set_position(ui.x + x - self.start_x,ui.y + y - self.start_y)
    self.start_x = x
    self.start_y = y
end

ac.game:notify('游戏-注册显示UI',ui)

return ui